#pragma once
#include <iostream>
#include <pthread.h>

class Mutex
{
public:
    Mutex(pthread_mutex_t* lock_p = nullptr)
        :_lock_p(lock_p)
    {}
    void lock()
    {
        pthread_mutex_lock(_lock_p);
    }
    void unlock()
    {
        pthread_mutex_unlock(_lock_p);
    }
    ~Mutex()    {}
private:
    pthread_mutex_t* _lock_p;
};

class lockGuard
{
public:
    lockGuard(pthread_mutex_t* mutex)
        :_mutex(mutex)
    {
        _mutex.lock();
    }
    ~lockGuard()
    {
        _mutex.unlock();
    }
private:
    Mutex _mutex;
};